﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;

public partial class article_sort : System.Web.UI.Page
{
    public Cstudy.MODEL.postclass postclass = new Cstudy.MODEL.postclass();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id;
            if (int.TryParse(Request.QueryString["sort"], out id))
            {
                postclass.CID = id;
                SelectClass();
                BindRepeater();
            }
        }
    }

    protected void SelectClass()
    {
        DataSet ds = new DataSet();
        Cstudy.BLL.postClass bllclass = new Cstudy.BLL.postClass();
        ds = bllclass.SelectPostClassByID(postclass.CID);
        postclass.CName = ds.Tables[0].Rows[0]["CName"].ToString();
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindRepeater();
    }

    protected void BindRepeater()
    {
        DataSet ds = new DataSet();
        int num;
        ds = new Cstudy.BLL.Artcles().SelectArtcleByClassID(postclass.CID, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out num, "@count");
        AspNetPager1.RecordCount = num;

        AspNetPager1.CustomInfoHTML = "总页数：" + AspNetPager1.PageCount;
        AspNetPager1.CustomInfoHTML += "当前页：" + AspNetPager1.CurrentPageIndex;
        AspNetPager1.CustomInfoHTML += "共" + AspNetPager1.RecordCount + "条记录";

        Repeater1.DataSource = ds;
        Repeater1.DataBind();
    }
}